*******************************************************************************
*
* Main Analysis
*
*******************************************************************************


clear all
set more off


* Import data
use "1_Data/master_data.dta"


*******************************************************************************
*
* Statistics mentioned in text
*
*******************************************************************************

mgof tails_w1 = binomialp(10, tails_w1, 0.5), mc ksmirnov


tab ten_tails_w1
display binomialp(10,10,0.5)


ttest ever_positive, by(ten_tails_w1)


spearman ever_positive likelihood_tails_w1



*******************************************************************************
*
* Table 1: ever_positive by tails in March 2020
*
*******************************************************************************


eststo clear

global controls_w1 age i.female educ_w1 hh_inc_w1 hh_18 ff_60 i.health_issue_w1 ///
	protect_others perception_gov_reg will_fin_risk


* Col 1: 10 Tails in W1
eststo: reg ever_positive ten_tails_w1, robust 
estadd local con "No"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)

* Col 2: 10 Tails in W1 + covariates
eststo: reg ever_positive ten_tails_w1 $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 3: 10 Tails in W1 with logit
logit ever_positive ten_tails_w1 , or
eststo: margins, dydx(*) post
estadd local con "No"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 4: 10 Tails in W1 + covariates with logit
logit ever_positive ten_tails_w1 $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 	

* Col 5: Likelihood of tails
eststo: reg ever_positive likelihood_tails_w1 , robust
estadd local con "No"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 6: Likelihood of tails + covariates
eststo: reg ever_positive likelihood_tails_w1 $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)

* Col 7: Likelihood of tails with logit
logit ever_positive likelihood_tails_w1 , or
eststo: margins, dydx(*) post
estadd local con "No"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 8: Likelihood of tails + covariates with logit
logit ever_positive likelihood_tails_w1 $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)


// Save table
esttab using  "3_Results/Tab_1.tex", replace ///
	keep(likelihood_tails_w1 ten_tails_w1 ) ///
	title("Positive corona test, truth-telling probability and ten tail tosses. \label{tab:main-table}") ///
	collabels(none) ///
	coeflabels(likelihood_tails_w1 "Likelihood of coin toss" ///
			   ten_tails_w1 "Reported ten tails") ///
	cells(b(fmt(3) star) se(par fmt(3))) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	booktabs ///
	nomtitles ///
	numbers ///
	nogaps ///
	style(tex) ///
	stats(con estimator N mean_positive_tests, label("Controls" "Estimator" "Observations" "Mean coronavirus infections") /// 
	fmt(0 0 0 3))



*******************************************************************************

* Table A1: Main Regressions with Control Variables

*******************************************************************************

eststo clear

global controls_w1 age female educ_w1 hh_inc_w1 hh_18 ff_60 health_issue_w1 ///
	protect_others perception_gov_reg will_fin_risk



* Col 2: 10 Tails in W1 + covariates
eststo: reg ever_positive ten_tails_w1 $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 


* Col 4: 10 Tails in W1 + covariates with logit
logit ever_positive ten_tails_w1 $controls_w1 , or 
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 	


* Col 6: Likelihood of tails + covariates
eststo: reg ever_positive likelihood_tails_w1 $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)


* Col 8: Likelihood of tails + covariates with logit
logit ever_positive likelihood_tails_w1 $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)


// Save table
esttab using  "3_Results/Tab_A1.tex", replace ///
	title("Positive corona test, truth-telling probability and ten tail tosses. \label{tab:main-table}") ///
	collabels(none) ///
	coeflabels(likelihood_tails_w1 "Likelihood of coin toss" ///
			   ten_tails_w1 "Reported ten tails" ///
			   age "Age in years" ///
			   female "Female (1=yes, =0)" ///
			   educ_w1 "Education" ///
			   hh_inc_w1 "Household income" ///
			   hh_18 "Number of HH members > 18 years" ///
			   ff_60 "Friends > 60 years" ///
			   health_issue_w1 "Health issue" ///
			   protect_others "Protective measures taken for others" ///
			   perception_gov_reg "Perception gov. regulation" ///
			   will_fin_risk "Willingness financial risk" ) ///
	cells(b(fmt(3) star) se(par fmt(3))) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	booktabs ///
	nomtitles ///
	numbers ///
	nogaps ///
	style(tex) ///
	stats(con estimator N mean_positive_tests, label("Controls" "Estimator" "Observations" "Mean coronavirus infections") /// 
	fmt(0 0 0 3))

	
	
	



*******************************************************************************

*Table A3: Robustness Measures

*******************************************************************************	
	
	
	
eststo clear

global controls_w1 age i.female educ_w1 hh_inc_w1 hh_18 ff_60 i.health_issue_w1 ///
	protect_others perception_gov_reg will_fin_risk


* Col 1: 9 and 10 Tails in W1
eststo: reg ever_positive nine_ten_tails_w1 , robust 
estadd local con "No"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)

* Col 2: 9 and 10 Tails in W1 + covariates
eststo: reg ever_positive nine_ten_tails_w1 $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 3: 9 and 10 Tails in W1 with logit
logit ever_positive nine_ten_tails_w1 , or
eststo: margins, dydx(*) post
estadd local con "No"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 4: 9 and 10 Tails in W1 + covariates with logit
logit ever_positive nine_ten_tails_w1 $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 	



* Col 1: 8, 9 and 10 Tails in W1
eststo: reg ever_positive eight_nine_ten_tails_w1 , robust 
estadd local con "No"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)

* Col 2: 8, 9 and 10 Tails in W1 + covariates
eststo: reg ever_positive  eight_nine_ten_tails_w1 $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 3: 8, 9 and 10 Tails in W1 with logit
logit ever_positive  eight_nine_ten_tails_w1 , or
eststo: margins, dydx(*) post
estadd local con "No"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 4: 8, 9 and 10 Tails in W1 + covariates with logit
logit ever_positive  eight_nine_ten_tails_w1 $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 	





// Save table 
//Latex
esttab using  "3_Results/TabA3.tex", replace ///
	keep(nine_ten_tails_w1 eight_nine_ten_tails_w1 ) ///
	title("Positive corona test and high number of tail tosses. \label{tab:main-table_rev}") ///
	collabels(none) ///
	coeflabels(nine_ten_tails_w1 "Reported nine or ten tails" ///
				eight_nine_ten_tails_w1 "Reported eight, nine or ten tails") ///
	cells(b(fmt(3) star) se(par fmt(3))) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	booktabs ///
	nomtitles ///
	numbers ///
	nogaps ///
	style(tex) ///
	stats(con estimator N mean_positive_tests, label("Controls" "Estimator" "Observations" "Mean coronavirus infections") /// 
	fmt(0 0 0 3))

//Word	
esttab using  "3_Results/TabA3", replace ///
	keep(nine_ten_tails_w1 eight_nine_ten_tails_w1 ) ///
	title("Positive corona test and high number of tail tosses.") ///
	collabels(none) ///
	coeflabels(nine_ten_tails_w1 "Reported nine or ten tails" ///
				eight_nine_ten_tails_w1 "Reported eight, nine or ten tails") ///
	cells(b(fmt(3) star) se(par fmt(3))) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	numbers ///
	stats(con estimator N mean_positive_tests, label("Controls" "Estimator" "Observations" "Mean coronavirus infections") /// 
	fmt(0 0 0 3))


	

	
*******************************************************************************

*Table A4: Robustness: Controlling for treatments in Main regression 

*******************************************************************************	
		

eststo clear

global controls_w1 age i.female educ_w1 hh_inc_w1 hh_18 ff_60 i.health_issue_w1 ///
	protect_others perception_gov_reg will_fin_risk
	
global treatments risk_treatment moral_treatment


* Col 1: 10 Tails in W1
eststo: reg ever_positive ten_tails_w1 $treatments , robust 
estadd local con "No"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)

* Col 2: 10 Tails in W1 + covariates
eststo: reg ever_positive ten_tails_w1 $treatments $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 3: 10 Tails in W1 with logit
logit ever_positive ten_tails_w1 $treatments , or
eststo: margins, dydx(*) post
estadd local con "No"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 4: 10 Tails in W1 + covariates with logit
logit ever_positive ten_tails_w1 $treatments $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 	

* Col 5: Likelihood of tails
eststo: reg ever_positive likelihood_tails_w1 $treatments , robust
estadd local con "No"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 6: Likelihood of tails + covariates
eststo: reg ever_positive likelihood_tails_w1 $treatments  $controls_w1 , robust 
estadd local con "Yes"
estadd local estimator "OLS"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)

* Col 7: Likelihood of tails with logit
logit ever_positive likelihood_tails_w1 $treatments , or
eststo: margins, dydx(*) post
estadd local con "No"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean) 

* Col 8: Likelihood of tails + covariates with logit
logit ever_positive likelihood_tails_w1 $treatments $controls_w1 , or
eststo: margins, dydx(*) post
estadd local con "Yes"
estadd local estimator "Logit"
summarize ever_positive  if !missing(likelihood_tails_w1)
estadd scalar mean_positive_tests = r(mean)


// Save table
//LaTeX
esttab using  "3_Results/TabA4", replace ///
	keep(likelihood_tails_w1 ten_tails_w1 ///
		$treatments) ///
	title("Positive corona test, truth-telling probability, ten tail tosses and treatments. \label{tab:main-table_rev2}") ///
	collabels(none) ///
	coeflabels(likelihood_tails_w1 "Likelihood of coin toss" ///
			   ten_tails_w1 "Reported ten tails") ///
	cells(b(fmt(3) star) se(par fmt(3))) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	booktabs ///
	nomtitles ///
	numbers ///
	nogaps ///
	style(tex) ///
	stats(con estimator N mean_positive_tests, label("Controls" "Estimator" "Observations" "Mean coronavirus infections") /// 
	fmt(0 0 0 3))


//Word

esttab using  "3_Results/TabA4", replace ///
	keep(likelihood_tails_w1 ten_tails_w1 ///
		$treatments) ///
	title("Positive corona test, truth-telling probability, ten tail tosses and treatments. \label{tab:main-table_rev2}") ///
	collabels(none) ///
	coeflabels(likelihood_tails_w1 "Likelihood of coin toss" ///
			   ten_tails_w1 "Reported ten tails") ///
	cells(b(fmt(3) star) se(par fmt(3))) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	nomtitles ///
	numbers ///
	stats(con estimator N mean_positive_tests, label("Controls" "Estimator" "Observations" "Mean coronavirus infections") /// 
	fmt(0 0 0 3))	



		
	
	

*******************************************************************************

* Cross Country Data and Analysis

*******************************************************************************

*** Data Preparation


use "1_Data/cross_country_data_wC.dta", clear

*load dataset with experimental data from Cohn et al. (2019) from the internet
//Cohn, A., Maréchal, M. A., Tannenbaum, D., & Zünd, C. L. (2019). Civic honesty around the globe. Science, 365(6448), 70–73. https://doi.org/10.1126/science.aau8712   

use "XYZ.dta"

*use data from money treatment only
keep if cond == 1 

regress response i.male i.above40 i.computer i.coworkers i.other_bystanders i.institution i.cond, cluster(country)
predict honesty_dv, residual

replace response = 1 if response == 100


replace Country = "United Kingdom" if Country == "UK"
replace Country = "United Arab Emirates" if Country == "UAE"
replace Country = "United States" if Country == "USA"
replace Country = "Czechia" if Country == "Czech Republic"


quietly describe, varlist
local vars `r(varlist)'
local omit Country name_owner
local want : list vars - omit
display "`want'"

collapse `want', by(Country)


summarize response, detail


merge 1:1 Country using "1_Data/cross_country_data_wC.dta"
drop _merge 


*generate variables 


label var response "Civic honesty"

label var cexcessmean "Cumulative COVID-19 excess deaths"

generate excess_rate = cexcessmean/population
label var excess_rate "Excess COVID-19 death rate"

summarize excess_rate
generate excess_rate_100 = excess_rate*100
label var excess_rate_100 "Excess COVID-19 death rate in \%"


generate OECD = 0
replace OECD = 1 if Country == "Australia"
replace OECD = 1 if Country == "Austria"
replace OECD = 1 if Country == "Belgium"
replace OECD = 1 if Country == "Canada"
replace OECD = 1 if Country == "Chile"
replace OECD = 1 if Country == "Colombia" 
replace OECD = 1 if Country == "Costa Rica"
replace OECD = 1 if Country == "Czechia"
replace OECD = 1 if Country == "Denmark"
replace OECD = 1 if Country == "Estonia"
replace OECD = 1 if Country == "Finland"
replace OECD = 1 if Country == "France"
replace OECD = 1 if Country == "Germany"
replace OECD = 1 if Country == "Greece"
replace OECD = 1 if Country == "Hungary"
replace OECD = 1 if Country == "Iceland"
replace OECD = 1 if Country == "Ireland"
replace OECD = 1 if Country == "Israel"
replace OECD = 1 if Country == "Italy"
replace OECD = 1 if Country == "Japan"
replace OECD = 1 if Country == "South Korea"
replace OECD = 1 if Country == "Latvia"
replace OECD = 1 if Country == "Lithuania"
replace OECD = 1 if Country == "Luxembourg"
replace OECD = 1 if Country == "Mexico"
replace OECD = 1 if Country == "Netherlands"
replace OECD = 1 if Country == "New Zealand"
replace OECD = 1 if Country == "Norway"
replace OECD = 1 if Country == "Poland"
replace OECD = 1 if Country == "Portugal"
replace OECD = 1 if Country == "Slovakia"
replace OECD = 1 if Country == "Slovenia"
replace OECD = 1 if Country == "Spain"
replace OECD = 1 if Country == "Sweden"
replace OECD = 1 if Country == "Switzerland"
replace OECD = 1 if Country == "Turkey"
replace OECD = 1 if Country == "United Kingdom"
replace OECD = 1 if Country == "United States"

label var OECD "OECD country"


save "1_Data/cross_country_data.dta", replace




***Analysis




spearman excess_rate_100 response if OECD==1

* Regression analysis with controls:

reg excess_rate_100 response if OECD==1, cluster(Country)

reg excess_rate_100 response populationvaccinated if OECD==1, cluster(Country)

reg excess_rate_100 response populationvaccinated  governmentresponseindex_average if OECD==1, cluster(Country)



